#include "ISNW_Material.h"
using namespace ISNW;

ISNW_Material::ISNW_Material()
:m_balive(ISNW_FALSE)
{
	memset(&m_material,0xFF,sizeof(m_material));
}

ISNW_Material::~ISNW_Material()
{
	m_balive = ISNW_FALSE;
}

ISNW_VOID ISNW_Material::SetColor(ISNW_MATERIAL_FORMAT f,D3DCOLORVALUE v)
{
	m_balive = ISNW_TRUE;
	switch(f){
		case ISNW_MATERIAL_SET_AMBIENT:
			m_material.Ambient = v;
			break;
		case ISNW_MATERIAL_SET_DIFFUSE:
			m_material.Diffuse = v;
			break;
		case ISNW_MATERIAL_SET_SPECULAR:
			m_material.Specular = v;
			break;
		case ISNW_MATERIAL_SET_EMISSIVE:
			m_material.Emissive = v;
			break;
		default:
			break;
	}
}

ISNW_VOID ISNW_Material::SetPower(float p)
{
	m_material.Power = p;
}

ISNW_VOID ISNW_Material::BeCurrMaterial()
{
	if(m_balive){
		if(g_pdevice){
			g_pdevice->SetMaterial(&m_material);
		}
	}
}